package com.jwsoft.manager.core.gateway.controller.common;

import cn.hutool.extra.servlet.ServletUtil;
import cn.hutool.system.SystemUtil;
import com.alibaba.fastjson.JSONArray;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.NoSignCrypto;
import com.jwsoft.manager.core.dao.service.EduStudentEnrollPreService;
import com.jwsoft.manager.core.integration.common.JhIrsIntegration;
import com.jwsoft.manager.core.integration.individuation.impl.JhIndividuationIntegrationImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "东阳大数据共享接口", description = "东阳大数据共享接口")
public class JhgxController {
    @Autowired
    JhIrsIntegration jhIrsIntegration;
    @Autowired
    JhIndividuationIntegrationImpl jhIndividuationIntegration;
    @Autowired
    EduStudentEnrollPreService eduStudentEnrollPreService;
    @GetMapping(value = "/JHGX0001")
    @Operation(summary = "获取金华的IRStoken信息",description = "获取金华的IRStoken信息")
    @NoSignCrypto
    public AppResponse<String> refreshTokenByKeyJh(){
        return AppResponse.successData(jhIrsIntegration.refreshTokenByKeyJh("",""));
    }
    @GetMapping(value = "/JHIRSGX0001")
    @Operation(summary = "获取IRS的token信息",description = "获取IRS的token信息")
    @NoSignCrypto
    public AppResponse<String> refreshTokenByKeyIrs(){
        return AppResponse.successData(jhIrsIntegration.refreshTokenByKeyIrs(null,null));
    }

    @GetMapping(value = "/JHGX0003")
    @Operation(summary = "金华市本级不动产权属信息查询（姓名+证件号）",description = "金华市本级不动产权属信息查询（姓名+证件号）")
    @NoSignCrypto
    public AppResponse<JSONArray> getPersonHouse(@Param("证件号码") @RequestParam("zjh") String zjh,
                                                 @Param("姓名") @RequestParam("name") String name,  HttpServletRequest request){
        String ip = ServletUtil.getClientIP(request);
        return AppResponse.successData(jhIrsIntegration.getFcJh(name,zjh,ip));
    }

    @GetMapping(value = "/JHIRSGX0007")
    @Operation(summary = "社会保险个人参保信息最新状态查询",description = "社会保险个人参保信息最新状态查询")
    @NoSignCrypto
    public AppResponse<JSONArray> getCbIrs( @Param("身份证号码")@RequestParam("aac002") String aac002, @Param("姓名")@RequestParam("aac003") String aac003,  HttpServletRequest request){
        String ip = ServletUtil.getClientIP(request);
        return AppResponse.successData(jhIrsIntegration.getCbIrs(aac002,ip));
    }
    @GetMapping(value = "/JHIRSGX0008")
    @Operation(summary = "社会保险个人参保缴费信息最新状态查询",description = "社会保险个人参保信息缴费最新状态查询")
    @NoSignCrypto
    public AppResponse<JSONArray> getCbJfIrs( @Param("身份证号码")@RequestParam("aac002") String aac002,
                                              @Param("姓名")@RequestParam("aac003") String aac003,
                                              @Param("开始时间")@RequestParam("aae030") String aae030,
                                              @Param("结束时间")@RequestParam("aae031") String aae031,
                                              @Param("险种")@RequestParam("aae140") String aae140,
                                              @Param("行政区划")@RequestParam("aab301") String aab301,  HttpServletRequest request){
        String ip = ServletUtil.getClientIP(request);
        return AppResponse.successData(jhIrsIntegration.getCbJfIrs(aac002,aac003,aae030,aae031,aae140,aab301,ip));
    }

    @GetMapping(value = "/JHIRSGX0003")
    @Operation(summary = "IRS省公安厅居民户口簿(家庭)", description = "省公安厅居民户口簿(家庭)")
    @NoSignCrypto
    public AppResponse<JSONArray> getFamilyInfoIrs(@Param("身份证号码") @RequestParam("czrkgmsfhm") String czrkgmsfhm,  HttpServletRequest request){
        String ip = ServletUtil.getClientIP(request);
        return AppResponse.successData(jhIrsIntegration.getFamilyInfoIrs(czrkgmsfhm,ip));
    }


    @GetMapping(value = "/JHIRSGX0005")
    @Operation(summary = "IRS省公安厅居住证", description = "IRS省公安厅居住证")
    @NoSignCrypto
    public AppResponse<JSONArray> getFamilyInfoIrs(@Param("身份证号码") @RequestParam("sfzh") String sfzh, @Param("姓名") @RequestParam("xm") String xm,  HttpServletRequest request) {
        String ip = ServletUtil.getClientIP(request);
        return AppResponse.successData(jhIrsIntegration.getJzzIrs(sfzh, xm,ip));
    }

}
